package com.hamster.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.hamster.crm.pojo.PersonalMoney;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @author Tarry
 * @create 2020/1/5 17:22
 */
@Mapper
@Repository
public interface PersonalMoneyMapper extends BaseMapper<PersonalMoney> {

    /**
     * 统计 总钱数
     * @param userId
     * @param curMonthTime
     * @param nextMonthTime
     * @return
     */
    @Select("select sum(money) AS count_money from personal_money where person_id = #{id} and create_time >= #{curDate} and create_time < #{nextDate}")
    Double queryCountMoney(@Param("id") String userId, @Param("curDate") Date curMonthTime, @Param("nextDate") Date nextMonthTime);
}
